package com.kefu.smartCall.vo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.vo.AbstractSearchVo;
import com.kefu.smartCall.model.ScTaskCall;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;

import javax.validation.constraints.Size;
import java.util.List;
import java.util.Objects;

@Data
@ToString(callSuper = true)
@ApiModel(description = "批量修改状态")
public class ScTaskCallBatchUpdateVo {
    @ApiModelProperty(name = "updateType", value = "批量方式", example="1",notes= "1 勾选修改 按照勾选的数据，2按照查询条件 根据查询条件修改")
    int updateType;

    @ApiModelProperty(name = "simpleUpdateVo", value = "勾选修改")
    SimpleUpdateVo simpleUpdateVo;

    @ApiModelProperty(name = "advancedRecovery", value = "根据查询条件修改")
    AdvancedUpdateVo advancedUpdateVo;

    @Data
    @ToString(callSuper = true)
    @ApiModel(description = "勾选修改")
    public static class SimpleUpdateVo {
        @Size(min=1)
        @ApiModelProperty(name = "taskCallIds", value = "待修改的记录id")
        List<String> taskCallIds;
        @ApiModelProperty(value = "大模型筛选状态 0=未选，-1=不通过，1=通过", name = "searchState")
        private Integer updateStatus;
    }

    @Data
    @ToString(callSuper = true)
    @ApiModel(description = "根据查询条件修改")
    public static class AdvancedUpdateVo extends AbstractSearchVo {
        @ApiModelProperty("任务")
        private String taskId;

        @ApiModelProperty(value = "用户回复数(大于这个数)")
        private Integer userMsgCountMin;

        @ApiModelProperty(value = "通话时长，秒(大于这个数)")
        private Integer callDurationMin;

        @ApiModelProperty(value = "大模型筛选状态 0=未选，-1=不通过，1=通过", name = "searchState")
        private Integer searchStatus;

        @ApiModelProperty(value = "大模型筛选状态-1=不通过，1=通过")
        private Integer updateStatus;

        @Override
        public LambdaQueryWrapper lambdaQuery() {
            LambdaQueryWrapper<ScTaskCall> wrapper = Wrappers.lambdaQuery(ScTaskCall.class);
            if (StrUtil.isNotBlank(taskId)) {
                wrapper.eq(ScTaskCall::getTaskId, taskId);
            }
            if (Objects.nonNull(userMsgCountMin)) {
                wrapper.gt(ScTaskCall::getUserMsgCount, userMsgCountMin);
            }
            if (Objects.nonNull(callDurationMin)) {
                wrapper.gt(ScTaskCall::getCallDuration, callDurationMin);
            }
            if (Objects.nonNull(searchStatus)) {
                wrapper.eq(ScTaskCall::getSearchStatus, searchStatus);
            }
            return wrapper;
        }
    }
}
